package com.ctshk.rpc.order.scenic.mapper.app;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.order.scenic.dto.app.AppScenicDTO;
import com.ctshk.rpc.order.scenic.dto.app.AppScenicOrderDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AppScenicOrderMapper extends BaseMapper {
    @Select("SELECT DISTINCT " +
            "`ctshk-ticket`.t_scenic_product.`name` AS productName,  " +
            "`ctshk-scenic-order`.t_scenic_order.product_id AS productId,  " +
            "`ctshk-scenic-order`.t_scenic_order.gmt_create AS gmtCreate,  " +
            "`ctshk-scenic-order`.t_scenic_order.order_amount AS orderAmount,  " +
            "`ctshk-scenic-order`.t_scenic_order.order_number AS orderNumber,  " +
            "`ctshk-scenic-order`.t_scenic_order.query_number AS queryNumber,  " +
            "`ctshk-scenic-order`.t_scenic_order.product_tickets_id AS productTicketsId,  " +
            "`ctshk-scenic-order`.t_scenic_order.product_ticket_number AS productTicketNumber,  " +
            "`ctshk-scenic-order`.t_scenic_order.integral AS integral,  " +
            "`ctshk-scenic-order`.t_scenic_order.contact_name AS contactName,  " +
            "`ctshk-scenic-order`.t_scenic_order.contact_mobile AS contactMobile,  " +
            "`ctshk-scenic-order`.t_scenic_order.contact_email AS contactEmail,  " +
            "`ctshk-scenic-order`.t_scenic_order.remark AS remark " +
            "FROM " +
            "`ctshk-ticket`.t_scenic_product, " +
            "`ctshk-scenic-order`.t_scenic_order " +
            "WHERE " +
            "( " +
            "`ctshk-ticket`.t_scenic_product.id = `ctshk-scenic-order`.t_scenic_order.product_id " +
            ") AND (`ctshk-scenic-order`.t_scenic_order.order_number = #{number} OR `ctshk-scenic-order`.t_scenic_order.query_number = #{number})")
    AppScenicOrderDTO findScenicOrderInfoByNumber(@Param("number") String number);

    @Select("SELECT " +
            "`ctshk-cloud`.t_scenic.`name` AS scenicName,  " +
            "`ctshk-cloud`.t_scenic.id AS scenicId " +
            "FROM " +
            "`ctshk-cloud`.t_scenic " +
            "WHERE `ctshk-cloud`.t_scenic.id in (${scenicIds})")
    List<AppScenicDTO> selectScenicNameByScenicIds(@Param("scenicIds") String scenicIds);
}
